<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateFlavorTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('flavor', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('business_id')->comment('商家id');
            $table->foreign('business_id')->references('id')->on('business');
            $table->string('flavor')->comment('口味');
            $table->timestamps();
        });
        Schema::create('order_flavor', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('order_id')->comment('商家id');
            $table->foreign('order_id')->references('id')->on('orders');
            $table->string('flavor_id')->comment('口味id');
            $table->foreign('flavor_id')->references('id')->on('flavor');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('order_flavor');
        Schema::dropIfExists('flavor');
    }
}
